/** 
  校际交流项目 - 学生申请
*/
<template>
    <div class="edu-page-warp topic-info">
        <div class="project-application-container" style="height: 30px;">
            <el-breadcrumb style="float: left;" separator="/">
                <el-breadcrumb-item :to="{ path: '/stuApplyList' }">
                    <span @click="returnList">校际交流项目学生申请</span>
                </el-breadcrumb-item>
                <el-breadcrumb-item>
                    <span v-if="submitType === 'add'">申请</span>
                    <span v-else-if="submitType === 'edit'">编辑</span>
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <el-card shadow="never">
            <el-button style="float:right" @click="returnList">返回</el-button>
            <span class="top-title">
                <h3 v-if="submitType === 'add'">校际交流项目学生申请-申请</h3>
                <h3 v-else-if="submitType === 'edit'">校际交流项目学生申请-编辑</h3>
            </span>
            <hr />
            <el-form
                :model="proForm"
                ref="proForm"
                :rules="baseInfoRules"
                label-position="right"
                label-suffix="："
            >
                <span class="topic-form-title">
                    <h3>个人信息</h3>
                </span>
                <el-row :gutter="24">
                    <el-col :span="6">
                        <el-form-item label="年级" prop="studentGrade">
                            <el-input
                                v-model="proForm.studentInfo.studentGrade"
                                class="topic-input-select"
                                disabled
                                maxlength="32"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="学院" prop="studentFacultyName">
                            <el-input
                                v-model="proForm.studentInfo.studentFacultyName"
                                class="topic-input-select"
                                disabled
                                maxlength="32"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="专业" prop="studentProfessionName">
                            <el-input
                                v-model="proForm.studentInfo.studentProfessionName"
                                class="topic-input-select"
                                disabled
                                maxlength="32"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="学号" prop="studentId">
                            <el-input
                                v-model="proForm.studentInfo.studentId"
                                class="topic-input-select"
                                disabled
                                maxlength="32"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="24">
                    <el-col :span="6">
                        <el-form-item label="姓名" prop="studentName">
                            <el-input
                                v-model="proForm.studentInfo.studentName"
                                class="topic-input-select"
                                disabled
                                maxlength="32"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="负责导师" prop="studentTeacherName">
                            <el-input
                                v-model="proForm.studentInfo.studentTeacherName"
                                class="topic-input-select"
                                disabled
                                maxlength="32"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="是否存在不及格课程" prop="studentExistFailed">
                            <el-select
                                v-model="proForm.studentInfo.studentExistFailed"
                                class="topic-input-select"
                                disabled
                                placeholder
                            >
                                <el-option
                                    v-for="item in source.lessons"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="博士论文是否开题" prop="studentThesisOpened">
                            <el-select
                                v-model="proForm.studentInfo.studentThesisOpened"
                                class="topic-input-select"
                                disabled
                                placeholder
                            >
                                <el-option
                                    v-for="item in source.isSelected"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="24">
                    <el-col :span="6">
                        <el-form-item label="培养层次" prop="studentTrainingLevel">
                            <el-input
                                v-model="proForm.studentInfo.studentTrainingLevel"
                                class="topic-input-select"
                                disabled
                                maxlength="32"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="手机号码" prop="studentInfo.studentPhone">
                            <el-input
                                v-model="proForm.studentInfo.studentPhone"
                                class="topic-input-select"
                                maxlength="32"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="电子邮件地址" prop="studentInfo.studentEmail">
                            <el-tooltip
                                class="item"
                                effect="light"
                                :content="proForm.studentInfo.studentEmail"
                                placement="top"
                                :disabled="showTip"
                            >
                                <el-input
                                    v-model="proForm.studentInfo.studentEmail"
                                    class="topic-input-select"
                                    maxlength="320"
                                ></el-input>
                            </el-tooltip>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="是否申请过对外交流项目" prop="studentOnceApproved">
                            <el-select
                                v-model="proForm.studentInfo.studentOnceApproved"
                                class="topic-input-select"
                                disabled
                                placeholder
                            >
                                <el-option
                                    v-for="item in source.lessons"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="24">
                    <el-col :span="12">
                        <el-form-item
                            label="对外交流项目类别"
                            prop="studentOnceApprovedNames"
                            v-show="proForm.studentInfo.studentOnceApproved"
                        >
                            <el-tooltip
                                class="item"
                                effect="light"
                                :content="proForm.studentInfo.studentOnceApprovedNames"
                                placement="top"
                                :disabled="showProTip"
                            >
                                <el-input
                                    v-model="proForm.studentInfo.studentOnceApprovedNames"
                                    class="topic-input-select"
                                    disabled
                                    maxlength="32"
                                ></el-input>
                            </el-tooltip>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="24">
                    <el-col :span="2">
                        <span class="topic-form-title">
                            <h3>申请项目情况</h3>
                        </span>
                    </el-col>
                </el-row>
                <el-row :gutter="24">
                    <el-col :span="6">
                        <el-form-item label="项目级别" prop="projectInfo.projectLevel">
                            <el-select
                                v-model="proForm.projectInfo.projectLevel"
                                class="topic-input-select"
                                filterable
                                @change="getProjectList"
                                placeholder
                            >
                                <el-option
                                    v-for="item in source.projectLevel"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="项目名称" prop="projectInfo.projectId">
                            <el-select
                                v-model="proForm.projectInfo.projectId"
                                class="topic-input-select"
                                filterable
                                @change="getData"
                                placeholder
                            >
                                <el-option
                                    v-for="item in source.projectList"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="培养层次" prop="projectInfo.teacherLevel">
                            <el-input
                                v-model="proForm.projectInfo.teacherLevel"
                                class="topic-input-select"
                                disabled
                                maxlength="32"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="24">
                    <el-col :span="12">
                        <el-form-item label="合作大学" prop="projectInfo.projectCollegeCn">
                            <el-input
                                v-model="proForm.projectInfo.projectCollegeCn"
                                class="topic-input-select"
                                maxlength="32"
                                disabled
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="合作大学英文名称" prop="projectInfo.projectCollegeEn">
                            <el-input
                                v-model="proForm.projectInfo.projectCollegeEn"
                                class="topic-input-select"
                                maxlength="32"
                                disabled
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="24">
                    <el-col :span="6">
                        <el-form-item label="国家/地区" prop="projectInfo.projectNationName">
                            <el-input
                                v-model="proForm.projectInfo.projectNationName"
                                class="topic-input-select"
                                disabled
                                maxlength="32"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="留学内容" prop="projectInfo.projectStudyAbroadContent">
                            <el-input
                                v-model="proForm.projectInfo.projectStudyAbroadContent"
                                class="topic-input-select"
                                disabled
                                maxlength="32"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="开始时间" prop="projectInfo.projectStartTime">
                            <el-date-picker
                                v-model="proForm.projectInfo.projectStartTime"
                                type="date"
                                disabled
                                class="topic-input-select"
                                value-format="yyyy-MM-dd HH:mm:ss"
                            ></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="结束时间" prop="projectInfo.projectEndTime">
                            <el-date-picker
                                v-model="proForm.projectInfo.projectEndTime"
                                type="date"
                                disabled
                                class="topic-input-select"
                                value-format="yyyy-MM-dd HH:mm:ss"
                            ></el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="24">
                    <el-col :span="6">
                        <el-form-item
                            label="每年中方留学生名额"
                            prop="projectInfo.projectInlandNumber"
                        >
                            <el-input
                                v-model="proForm.projectInfo.projectInlandNumber"
                                class="topic-input-select"
                                disabled
                                maxlength="32"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item
                            label="每年外方留学生名额"
                            prop="projectInfo.projectOutlandNumber"
                        >
                            <el-input
                                v-model="proForm.projectInfo.projectOutlandNumber"
                                class="topic-input-select"
                                disabled
                                maxlength="32"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="项目负责人" prop="projectInfo.projectHeadLable">
                            <el-input
                                v-model="proForm.projectInfo.projectHeadLable"
                                class="topic-input-select"
                                disabled
                                maxlength="32"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="项目联络人" prop="projectInfo.projectContactLable">
                            <el-input
                                v-model="proForm.projectInfo.projectContactLable"
                                class="topic-input-select"
                                disabled
                                maxlength="32"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="24">
                    <el-col :span="12">
                        <el-form-item label="所涉及学院（可多选）" prop="projectInfo.facultly">
                            <el-input
                                v-model="proForm.projectInfo.facultly"
                                class="topic-input-select"
                                disabled
                                type="textarea"
                                autosize
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="24">
                    <el-col :span="24">
                        <el-form-item label="备注" prop="projectInfo.projectRemark">
                            <el-input
                                v-model="proForm.projectInfo.projectRemark"
                                disabled
                                class="topic-input-select"
                                type="textarea"
                                :rows="4"
                                maxlength="500"
                                show-word-limit
                                placeholder
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="24">
                    <el-col :span="2">
                        <span class="topic-form-title">
                            <h3>学生外语水平</h3>
                        </span>
                    </el-col>
                </el-row>
                <el-row :gutter="24">
                    <el-col :span="6">
                        <el-form-item label="外语成绩" prop="studentInfo.foreignScore">
                            <el-input
                                v-model="proForm.studentInfo.foreignScore"
                                class="topic-input-select"
                                placeholder="请输入（例如：雅思6.6）"
                                maxlength="32"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="24">
                    <el-col :span="2">
                        <span class="topic-form-title">
                            <h3>学术成果</h3>
                        </span>
                    </el-col>
                    <div
                        style="float:right; padding-right:10px;line-height: 60px;text-align: center;"
                    >
                        <el-button size="small" type="primary" @click="addLine">新增</el-button>
                    </div>
                </el-row>

                <el-form :model="diyTable" ref="diyTable" :rules="rulesForm">
                    <edu-table
                        :pagination="false"
                        :order="false"
                        :tooltipEffect="tooltipEffect"
                        stripe
                        :data="diyTable.achievementList"
                        size="mini"
                        :selection="false"
                    >
                        <edu-table-column label="论文名称" prop="paperName" min-width="110">
                            <template slot-scope="scope">
                                <el-form-item
                                    style="margin-top: 15px;"
                                    :prop="'achievementList.' + scope.$index + '.paperName'"
                                    label-width="0"
                                >
                                    <el-input
                                        v-model.trim="scope.row.paperName"
                                        maxlength="32"
                                        type="textarea"
                                        clearable
                                        autosize
                                        placeholder="In Situ Selective…"
                                        style="width: 100%"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </edu-table-column>
                        <edu-table-column label="期刊" prop="periodical" min-width="118">
                            <template slot-scope="scope">
                                <el-form-item
                                    style="margin-top: 15px;"
                                    :prop="'achievementList.' + scope.$index + '.periodical'"
                                    label-width="0"
                                >
                                    <el-input
                                        v-model.trim="scope.row.periodical"
                                        maxlength="32"
                                        type="textarea"
                                        clearable
                                        autosize
                                        placeholder="IEEE GEOSCIENCE"
                                        style="width: 100%"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </edu-table-column>
                        <edu-table-column label="作者排名" prop="authorRanking" min-width="88">
                            <template slot-scope="scope">
                                <el-form-item
                                    style="margin-top: 15px;"
                                    :prop="'achievementList.' + scope.$index + '.authorRanking'"
                                    label-width="0"
                                >
                                    <el-input
                                        v-model.trim="scope.row.authorRanking"
                                        clearable
                                        type="textarea"
                                        autosize
                                        maxlength="32"
                                        placeholder="一"
                                        style="width: 100%"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </edu-table-column>
                        <edu-table-column
                            :render-header="renderHeader"
                            prop="recordSituation"
                            min-width="124"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    style="margin-top: 15px;"
                                    :prop="'achievementList.' + scope.$index + '.recordSituation'"
                                    label-width="0"
                                >
                                    <el-input
                                        v-model.trim="scope.row.recordSituation"
                                        clearable
                                        type="textarea"
                                        autosize
                                        maxlength="32"
                                        placeholder="SCI"
                                        style="width: 100%"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </edu-table-column>
                        <edu-table-column
                            :render-header="renderYear"
                            prop="publicationTime"
                            min-width="108"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    style="margin-top: 15px;"
                                    :prop="'achievementList.' + scope.$index + '.publicationTime'"
                                    label-width="0"
                                >
                                    <el-date-picker
                                        v-model="scope.row.publicationTime"
                                        value-format="yyyy-MM"
                                        format="yyyy 年 MM 月"
                                        type="month"
                                        placeholder="选择年月"
                                        style="width: 100%"
                                    ></el-date-picker>
                                </el-form-item>
                            </template>
                        </edu-table-column>
                        <edu-table-column
                            :render-header="renderHeader3"
                            prop="phaseVolumePage"
                            min-width="126"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    style="margin-top: 15px;"
                                    :prop="'achievementList.' + scope.$index + '.phaseVolumePage'"
                                    label-width="0"
                                >
                                    <el-input
                                        v-model.trim="scope.row.phaseVolumePage"
                                        clearable
                                        type="textarea"
                                        autosize
                                        maxlength="32"
                                        placeholder="101(4):632-636"
                                        style="width: 100%"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </edu-table-column>
                        <edu-table-column
                            :render-header="renderHeader2"
                            prop="mainPartner"
                            min-width="224"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    style="margin-top: 15px;"
                                    :prop="'achievementList.' + scope.$index + '.mainPartner'"
                                    label-width="0"
                                >
                                    <el-input
                                        v-model.trim="scope.row.mainPartner"
                                        clearable
                                        type="textarea"
                                        autosize
                                        maxlength="32"
                                        placeholder="谢欢"
                                        style="width: 100%"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </edu-table-column>
                        <edu-table-column label="语种" prop="language" min-width="100">
                            <template slot-scope="scope">
                                <el-form-item
                                    style="margin-top: 15px; "
                                    :prop="'achievementList.' + scope.$index + '.language'"
                                    label-width="0"
                                >
                                    <el-input
                                        v-model.trim="scope.row.language"
                                        clearable
                                        autosize
                                        type="textarea"
                                        maxlength="32"
                                        placeholder="英文"
                                        style="width: 100%"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </edu-table-column>
                        <edu-table-column prop="address" label="操作" min-width="70">
                            <template slot-scope="scope">
                                <el-button
                                    type="text"
                                    @click="deleteRoster(scope.row, scope.$index)"
                                >
                                    删除
                                </el-button>
                            </template>
                        </edu-table-column>
                    </edu-table>
                </el-form>
                <!-- <br />
                <el-row :gutter="24">
                    <el-col :span="4">
                        <span class="topic-form-title">
                            <h3 style="float: left">附件管理（项目附件）</h3>
                        </span>
                    </el-col>
                </el-row>
                <edu-table
                    :data="uploadFileList"
                    :tooltipEffect="tooltipEffect"
                    stripe
                    :selection="false"
                    :order="false"
                    :pagination="false"
                >
                    <edu-table-column prop label="已上传文件">
                        <template slot-scope="scope">
                            <el-button type="text" @click="downFile(scope.row)">
                                {{ scope.row.fileName }}
                            </el-button>
                        </template>
                    </edu-table-column>
                    <edu-table-column prop="fileExt" label="文件类型"></edu-table-column>
                    <edu-table-column prop="fileTime" label="上传时间"></edu-table-column>
                    <edu-table-column prop="fileSize" label="文件大小"></edu-table-column>
                </edu-table> -->
            </el-form>

            <br />
            <div>
                <span class="topic-form-title">
                    <h3>出国/境及经费历史信息</h3>
                </span>
                <el-table :data="pgExchangeHistory">
                    <el-table-column
                        prop="destinationCountry"
                        label="出国/境目的地"
                    ></el-table-column>
                    <el-table-column
                        prop="thesisOpened"
                        label="博士论文是否开题"
                        v-if="ifThesis"
                        width="180px"
                    ></el-table-column>
                    <el-table-column prop="inviteAgency" label="邀请单位名称"></el-table-column>
                    <el-table-column prop="planStartTime" label="预计出国时间"></el-table-column>
                    <el-table-column prop="planEndTime" label="预计回国时间"></el-table-column>
                    <el-table-column prop="realEndTime" label="实际回国时间"></el-table-column>
                    <el-table-column prop="backStatus" label="回国登记状态"></el-table-column>
                    <el-table-column prop="grantingAgency" label="出资单位"></el-table-column>
                    <el-table-column prop label="审核状态"></el-table-column>
                </el-table>
            </div>
            <div>
                <hr />
                <div class="edu-opertion-bar">
                    <div class="float-right">
                        <el-button @click="onCancel">取消</el-button>
                        <el-button type="primary" @click="onSubmit(0)">保存</el-button>
                        <el-button type="primary" @click="onSubmit(1)">提交</el-button>
                    </div>
                </div>
            </div>
        </el-card>
    </div>
</template>
<script>
import filters from 'common/src/filters'
import { downloadfile } from 'common/src/api/upload'
import { queryDic } from 'common/src/api/dictionary'
import UTILS from 'common/src/utils/utils'
import stuApplyApi from 'common/src/api/interSchoolExchange/stuApply'
import InterSchoolComAppApi from 'common/src/api/interSchoolExchange/InterSchoolComApp'
import * as INDEX from 'common/src/utils/index'

export default {
    props: {
        id: {
            type: Number,
            default: null
        },
        submitType: {
            type: String,
            default: ''
        }
    },
    data() {
        return {
            source: {
                isSelected: [
                    {
                        value: '0',
                        label: '否'
                    },
                    {
                        value: '1',
                        label: '是'
                    },
                    {
                        value: '',
                        label: '-'
                    }
                ],
                lessons: [
                    {
                        value: false,
                        label: '否'
                    },
                    {
                        value: true,
                        label: '是'
                    }
                ],
                trainingLevel: [],
                showTip: true,
                showProTip: true,
                projectLevel: [
                    {
                        value: 1,
                        label: '院级'
                    },
                    {
                        value: 2,
                        label: '校级'
                    }
                ],
                projectList: []
            },
            uploadFileList: [],

            // 动态表单参数
            diyTable: {
                achievementList: []
            },
            processes: [],

            proForm: {
                studentInfo: {
                    studentTeacher: '',
                    studentTrainingLevelCode: '',
                    studentFaculty: '',
                    studentId: '',
                    studentName: '',
                    studentFacultyName: '',
                    studentProfessionName: '',
                    studentGrade: '',
                    studentFormLearning: '',
                    studentLeaveSchool: '',
                    studentTeacherName: '',
                    studentTrainingLevel: '',
                    studentTrainingCategory: '',
                    studentExpectedGraduationDate: '',
                    studentPhone: '',
                    studentEmail: '',
                    studentExistFailed: '',
                    studentThesisOpened: '',
                    studentEnrolCategory: '',
                    studentOnceApproved: '',
                    studentOnceApprovedNames: '',
                    foreignScore: ''
                },
                projectInfo: {
                    teacherLevelCode: '',
                    projectHeadId: '',
                    projectId: null,
                    projectLevel: null,
                    projectCollegeCn: '',
                    projectCollegeEn: '',
                    projectNationName: '',
                    projectStudyAbroadContent: '',
                    projectStartTime: '',
                    projectEndTime: '',
                    projectInlandNumber: '',
                    projectOutlandNumber: '',
                    projectHeadLable: '',
                    projectContactLable: '',
                    contactId: '',
                    projectRemark: '',
                    teacherLevel: '',
                    facultly: ''
                }
            },
            submitFileList: [],
            baseInfoRules: {
                studentInfo: {
                    studentPhone: [
                        { required: true, message: '请输入', trigger: 'blur' },
                        { validator: this.checkPhone, trigger: 'blur' }
                    ], //电话号码
                    studentEmail: [
                        { required: true, message: '请输入', trigger: 'blur' },
                        { validator: this.checkEmail, trigger: 'blur' }
                    ], // 邮箱
                    foreignScore: [{ required: true, message: '请输入', trigger: 'blur' }] // 外语成绩
                },
                projectInfo: {
                    projectLevel: [{ required: true, message: '请选择', trigger: 'change' }],
                    projectId: [{ required: true, message: '请选择', trigger: 'change' }]
                }
            },
            uploadConfig: {
                data: { bucketname: 'face', folderpath: 'file' }
            }
        }
    },
    filters: {
        result(val) {
            switch (val) {
                case 'Process':
                    return '通过'
                case 'Reject':
                    return '驳回'
                case 'Recall':
                    return '撤回'
                case 'End':
                    return '通过'
                case 'COMMIT':
                    return '已提交'
                case 'NoPass':
                    return '不通过'
                default:
                    return ' '
            }
        }
    },
    watch: {
        'proForm.studentInfo.studentEmail': {
            handler(newVal) {
                if (newVal && newVal.length > 20) {
                    this.showTip = false
                } else {
                    this.showTip = true
                }
            },
            deep: true,
            immediate: true
        },
        'proForm.studentInfo.studentOnceApprovedNames': {
            handler(newVal) {
                if (newVal && newVal.length > 20) {
                    this.showProTip = false
                } else {
                    this.showProTip = true
                }
            },
            deep: true,
            immediate: true
        }
    },
    created() {
        this.getStuInfo()
        this.getTeacherLevel()
        // if (this.submitType === 'edit') {
        //     this.getEditInfo()
        // }
    },
    mounted() {},
    methods: {
        // 校验手机号码
        checkPhone(rule, value, callback) {
            let regExp = /^1[23456789]\d{9}$/
            if (!regExp.test(value)) {
                callback(new Error(this.$t('projectApplication.validateStudentPhone')))
            } else {
                callback()
            }
        },
        // 校验电子邮件地址
        checkEmail(rule, value, callback) {
            let regExp = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
            if (!regExp.test(value)) {
                callback(new Error(this.$t('projectApplication.validateStudentEmail')))
            } else {
                callback()
            }
        },

        // 返回列表页
        returnList() {
            this.$confirm('取消将不会保存当前设置，是否确定?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$emit('returnVal', 'list')
            })
        },

        // 获取培养层次
        async getTeacherLevel() {
            InterSchoolComAppApi.queryTrainings().then(res => {
                res.data.forEach(level => {
                    this.source.trainingLevel.push({
                        label: level.trainingName,
                        value: level.trainingCode
                    })
                })
            })
        },

        // 编辑页获取初始信息
        // getEditInfo() {
        //     let _this = this
        //     stuApplyApi.detailApply({ id: this.id }).then(res => {
        //         if (res.code === 200 && res.data.projectInfo && res.data.projectInfo.projectId) {
        //             _this.getData(res.data.projectInfo.projectId)
        //             _this.getProjectList(res.data.projectInfo.projectLevel,)
        //             _this.proForm.projectInfo.projectLevel = res.data.projectInfo.projectLevel
        //             _this.proForm.projectInfo.projectId = res.data.projectInfo.projectId
        //             _this.proForm.studentInfo.studentId = res.data.studentInfo.studentId
        //             _this.proForm.studentInfo.studentOnceApprovedNames =
        //                 res.data.studentInfo.studentOnceApprovedNames
        //             _this.proForm.studentInfo.studentPhone = res.data.studentInfo.studentPhone
        //             _this.proForm.studentInfo.studentEmail = res.data.studentInfo.studentEmail
        //             _this.proForm.studentInfo.foreignScore = res.data.studentInfo.foreignScore
        //             _this.diyTable.achievementList = res.data.achievementList
        //             // this.$set(_this.diyTable, 'achievementList' ,res.data.achievementList)
        //             _this.approveList = res.data.approveList
        //         }
        //     })
        // },

        // 获取学生信息
        getStuInfo() {
            let _this = this
            stuApplyApi.studentDetail('').then(res => {
                this.proForm.studentInfo.studentGrade = res.data.studentGrade
                this.proForm.studentInfo.studentFacultyName = res.data.studentFacultyName
                this.proForm.studentInfo.studentProfessionName = res.data.studentProfessionName
                this.proForm.studentInfo.studentName = res.data.studentName
                this.proForm.studentInfo.studentTeacherName = res.data.studentTeacherName
                this.proForm.studentInfo.studentThesisOpened = res.data.studentThesisOpened
                this.proForm.studentInfo.studentOnceApproved = res.data.studentOnceApproved
                this.proForm.studentInfo.studentTrainingLevel = res.data.studentTrainingLevel
                this.proForm.studentInfo.studentExistFailed = res.data.studentExistFailed
                this.proForm.studentInfo.studentFaculty = res.data.studentFaculty
                this.proForm.studentInfo.studentTrainingLevelCode =
                    res.data.studentTrainingLevelCode
                this.proForm.studentInfo.studentTeacher = res.data.studentTeacher
                if (this.submitType === 'add') {
                    this.proForm.studentInfo.studentPhone = res.data.studentPhone
                    this.proForm.studentInfo.studentEmail = res.data.studentEmail
                    this.proForm.studentInfo.studentId = res.data.studentId
                    this.proForm.studentInfo.studentOnceApprovedNames =
                        res.data.studentOnceApprovedNames
                } else if (this.submitType === 'edit') {
                    // 获取编辑页详情
                    stuApplyApi.detailApply({ id: _this.id }).then(resT => {
                        if (
                            resT.code === 200 &&
                            resT.data.projectInfo &&
                            resT.data.projectInfo.projectId
                        ) {
                            // 获取项目信息
                            _this.getData(resT.data.projectInfo.projectId)
                            // 获取项目名称
                            _this.getProjectList(
                                resT.data.projectInfo.projectLevel,
                                res.data.studentTrainingLevelCode,
                                res.data.studentFaculty
                            )
                            _this.proForm.projectInfo.projectLevel =
                                resT.data.projectInfo.projectLevel
                            _this.proForm.projectInfo.projectId = resT.data.projectInfo.projectId
                            _this.proForm.studentInfo.studentId = resT.data.studentInfo.studentId
                            _this.proForm.studentInfo.studentOnceApprovedNames =
                                resT.data.studentInfo.studentOnceApprovedNames
                            _this.proForm.studentInfo.studentPhone =
                                resT.data.studentInfo.studentPhone
                            _this.proForm.studentInfo.studentEmail =
                                resT.data.studentInfo.studentEmail
                            _this.proForm.studentInfo.foreignScore =
                                resT.data.studentInfo.foreignScore
                            _this.diyTable.achievementList = resT.data.achievementList
                            // this.$set(_this.diyTable, 'achievementList' ,res.data.achievementList)
                            _this.approveList = resT.data.approveList
                        }
                    })
                }
            })
        },

        // 获取项目详情
        getData(val) {
            this.proForm.projectInfo.teacherLevel = ''
            this.proForm.projectInfo.facultly = ''

            let parm = {
                projectId: this.proForm.projectInfo.projectId
            }
            if (this.submitType === 'edit') {
                parm.projectId = val
            }
            InterSchoolComAppApi.get(parm).then(res => {
                this.proForm.projectInfo.projectCollegeCn = res.data.projectCollegeCn
                this.proForm.projectInfo.projectCollegeEn = res.data.projectCollegeEn
                this.proForm.projectInfo.projectNationName = res.data.projectNationName
                this.proForm.projectInfo.projectStudyAbroadContent =
                    res.data.projectStudyAbroadContent
                this.proForm.projectInfo.projectStartTime = res.data.projectStartTime
                this.proForm.projectInfo.projectEndTime = res.data.projectEndTime
                this.proForm.projectInfo.projectInlandNumber = res.data.projectInlandNumber
                this.proForm.projectInfo.projectOutlandNumber = res.data.projectOutlandNumber
                this.proForm.projectInfo.projectHeadLable = res.data.projectHeadLable
                this.proForm.projectInfo.projectContactLable = res.data.projectContactLable
                this.proForm.projectInfo.contactId = res.data.projectContactId
                this.proForm.projectInfo.projectRemark = res.data.projectRemark
                this.proForm.projectInfo.projectHeadId = res.data.projectHeadId
                res.data.faculties.forEach(fac => {
                    if (this.proForm.projectInfo.facultly) {
                        this.proForm.projectInfo.facultly =
                            this.proForm.projectInfo.facultly + ',' + fac.facultyName
                    } else {
                        this.proForm.projectInfo.facultly = fac.facultyName
                    }
                })
                res.data.trainings.forEach(tra => {
                    if (this.proForm.projectInfo.teacherLevel) {
                        this.proForm.projectInfo.teacherLevel =
                            this.proForm.projectInfo.teacherLevel + ',' + tra.trainingName
                        this.proForm.projectInfo.teacherLevelCode =
                            this.proForm.projectInfo.teacherLevelCode + ',' + tra.trainingCode
                    } else {
                        this.proForm.projectInfo.teacherLevel = tra.trainingName
                        this.proForm.projectInfo.teacherLevelCode = tra.trainingCode
                    }
                })
                // this.uploadFileList = res.data.files
                this.processes = res.data.processes
            })
        },

        // 获取项目名称
        getProjectList(pro, tra, col) {
            this.source.projectList = []
            this.proForm.projectInfo.projectId = null
            this.proForm.projectInfo.teacherLevelCode = ''
            this.proForm.projectInfo.projectCollegeCn = ''
            this.proForm.projectInfo.projectCollegeEn = ''
            this.proForm.projectInfo.projectNationName = ''
            this.proForm.projectInfo.projectStudyAbroadContent = ''
            this.proForm.projectInfo.projectStartTime = ''
            this.proForm.projectInfo.projectEndTime = ''
            this.proForm.projectInfo.projectInlandNumber = ''
            this.proForm.projectInfo.projectOutlandNumber = ''
            this.proForm.projectInfo.projectHeadLable = ''
            this.proForm.projectInfo.projectContactLable = ''
            this.proForm.projectInfo.contactId = ''
            this.proForm.projectInfo.projectRemark = ''
            this.proForm.projectInfo.teacherLevel = ''
            this.proForm.projectInfo.facultly = ''
            this.proForm.projectInfo.projectHeadId = ''

            let parm = {
                projectLevel: this.proForm.projectInfo.projectLevel,
                trainingLevel: this.proForm.studentInfo.studentTrainingLevelCode,
                college: this.proForm.studentInfo.studentFaculty
            }
            if (this.submitType === 'edit' && pro && tra && col) {
                parm.projectLevel = pro
                parm.trainingLevel = tra
                parm.college = col
            }
            stuApplyApi.projectList(parm).then(res => {
                if (res.code === 200) {
                    res.data.forEach(val => {
                        this.source.projectList.push({
                            label: val.projectName,
                            value: val.projectId
                        })
                    })
                }
            })
        },

        // 新增行
        addLine() {
            if (this.diyTable.achievementList.length > 4) {
                this.$message.error('最多只能新增5个学术成果')
            } else {
                this.diyTable.achievementList.push({
                    uniqueId: new Date().getTime(),
                    publicationTime: '',
                    phaseVolumePage: '',
                    periodical: '',
                    mainPartner: '',
                    language: '',
                    authorRanking: '',
                    recordSituation: '',
                    paperName: ''
                })
            }
        },
        // 删除行
        deleteRoster(row, index) {
            this.diyTable.achievementList.splice(index, 1)
        },

        // 提交
        onSubmit(status) {
            let parm = {
                submitType: status,
                studentInfo: {
                    studentId: this.proForm.studentInfo.studentId,
                    tutorId: this.proForm.studentInfo.studentTeacher,
                    studentOnceApprovedNames: this.proForm.studentInfo.studentOnceApprovedNames,
                    studentPhone: this.proForm.studentInfo.studentPhone,
                    studentEmail: this.proForm.studentInfo.studentEmail,
                    foreignScore: this.proForm.studentInfo.foreignScore
                },
                projectInfo: {
                    projectLevel: this.proForm.projectInfo.projectLevel,
                    trainingLevel: this.proForm.projectInfo.teacherLevelCode,
                    projectId: this.proForm.projectInfo.projectId,
                    principalId: this.proForm.projectInfo.projectHeadId,
                    contactId: this.proForm.projectInfo.contactId
                },

                achievementList: []
            }
            this.diyTable.achievementList.forEach(val => {
                if (
                    val.publicationTime !== '' ||
                    val.phaseVolumePage !== '' ||
                    val.periodical !== '' ||
                    val.mainPartner !== '' ||
                    val.language !== '' ||
                    val.authorRanking !== '' ||
                    val.recordSituation !== '' ||
                    val.paperName !== ''
                ) {
                    parm.achievementList.push(val)
                }
            })
            this.$refs.proForm.validate(valid => {
                if (valid) {
                    if (this.submitType === 'add') {
                        stuApplyApi.studentApply(parm).then(res => {
                            if (res.code === 200) {
                                if (status === 0) {
                                    this.$message({
                                        message: '保存成功',
                                        type: 'success'
                                    })
                                } else if (status === 1) {
                                    this.$message({
                                        message: '提交成功',
                                        type: 'success'
                                    })
                                }
                                this.$emit('returnVal', 'list')
                            }
                        })
                    } else if (this.submitType === 'edit') {
                        parm.id = this.id
                        stuApplyApi.editApply(parm).then(res => {
                            if (res.code === 200) {
                                if (status === 0) {
                                    this.$message({
                                        message: '保存成功',
                                        type: 'success'
                                    })
                                } else if (status === 1) {
                                    this.$message({
                                        message: '提交成功',
                                        type: 'success'
                                    })
                                }
                                this.$emit('returnVal', 'list')
                            }
                        })
                    }
                }
            })
        },

        // 取消
        onCancel() {
            this.$confirm('取消将不会保存当前设置，是否确定?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$emit('returnVal', 'list')
            })
        },
        downFile(row) {
            downloadfile(row.fileId)
        },
        renderHeader(h, para) {
            return h('div', {
                attrs: {
                    class: 'cell'
                },
                domProps: {
                    innerHTML: '收录情况如</br>SCI/EI收录等'
                }
            })
        },
        renderHeader2(h, para) {
            return h('div', {
                attrs: {
                    class: 'cell'
                },
                domProps: {
                    innerHTML: '主要合作者</br>如有校内导师请填写导师姓名'
                }
            })
        },
        renderHeader3(h, para) {
            return h('div', {
                attrs: {
                    class: 'cell'
                },
                domProps: {
                    innerHTML: '卷/期/页</br>著作论文填写'
                }
            })
        },
        renderYear(h, para) {
            return h('div', {
                attrs: {
                    class: 'cell'
                },
                domProps: {
                    innerHTML: '发表时间</br>（年/月）'
                }
            })
        }
    }
}
</script>
<style lang="scss" scoped>
.project-application-container {
    .el-breadcrumb__item:last-child ::v-deep {
        .el-breadcrumb__inner {
            color: #606266;
            font-weight: bold;
            cursor: default;
        }
    }
    .el-breadcrumb__item ::v-deep {
        .is-link {
            color: #aaa;
            font-weight: unset;
        }
        .is-link:hover {
            color: #409eff;
        }
    }
}

.topic-info {
    .topic-title {
        color: #2b3b4e;
        font-size: 18px;
        line-height: 24px;
        font-weight: bold;
    }
    .item {
        margin: 0px;
    }
    .topic-expand {
        color: #3a7fe8;
        font-size: 14px;
        cursor: pointer;
        margin-left: 10px;
    }
    .topic-input-select {
        width: 100%;
    }
    .topic-form-title {
        font-weight: bold;
        text-align: left;
        line-height: 60px;
    }
    .topic-form-down {
        text-align: left;
        line-height: 60px;
    }
    .top-title {
        font-weight: bold;
        text-align: left;
        line-height: 30px;
    }
    .bottom-btn {
        margin-bottom: 10px;
    }
    .upload-demo {
        text-align: center;
    }
}
</style>